﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class GameOrderService
    {
        //大类
        //精选游戏价格升序
        public static List<Game> SeleJXJGShengGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Upcount>300 order by Gm_Price");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }
        
        //精选游戏价格降序
        public static List<Game> SeleJXJGJiangGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Upcount>300 order by Gm_Price desc");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //精选游戏人气升序
        public static List<Game> SeleJXRQShengGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Upcount>300 order by Gm_Upcount");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //精选游戏人气降序
        public static List<Game> SeleJXRQJiangGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Upcount>300 order by Gm_Upcount desc");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //免费游戏人气升序 
        public static List<Game> SeleMFRQShengGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Price=0 order by Gm_Upcount");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //免费游戏人气降序 
        public static List<Game> SeleMFRQJiangGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Price=0 order by Gm_Upcount desc");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //付费游戏价格升序 
        public static List<Game> SeleFFJGShengGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Price>0 order by Gm_Price");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //付费游戏价格降序 
        public static List<Game> SeleFFJGJiangGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Price>0 order by Gm_Price desc");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //付费游戏人气升序 
        public static List<Game> SeleFFRQShengGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Price>0 order by Gm_Upcount");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //付费游戏人气升序 
        public static List<Game> SeleFFRQJiangGame()
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_Price>0 order by Gm_Upcount desc");
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }


        //小类
        //游戏价格升序
        public static List<Game> SeleMinJGShengGame(int id)
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_TypeId='{0}' order by Gm_Price",id);
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //游戏价格降序
        public static List<Game> SeleMinJGJiangGame(int id)
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_TypeId='{0}' order by Gm_Price desc",id);
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //人气升序
        public static List<Game> SeleMinRQShengGame(int id)
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_TypeId='{0}' order by Gm_Upcount",id);
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

        //人气降序
        public static List<Game> SeleMinRQJiangGame(int id)
        {
            List<Game> item = new List<Game>();
            string sql = string.Format("select * from Game where Gm_TypeId='{0}' order by Gm_Upcount desc",id);
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Game gm = new Game();
                    gm.Gm_Id = Convert.ToInt32(dt.Rows[i]["Gm_Id"].ToString());
                    gm.Gm_Name = dt.Rows[i]["Gm_Name"].ToString();
                    gm.Gm_TypeId = Convert.ToChar(dt.Rows[i]["Gm_TypeId"].ToString());
                    gm.Gm_Price = Convert.ToDouble(dt.Rows[i]["Gm_Price"].ToString());
                    gm.Gm_Image = dt.Rows[i]["Gm_Image"].ToString();
                    gm.Gm_Lv = dt.Rows[i]["Gm_Lv"].ToString();
                    gm.Gm_Desc = dt.Rows[i]["Gm_Desc"].ToString();
                    gm.Gm_Upcount = Convert.ToInt32(dt.Rows[i]["Gm_Upcount"].ToString());
                    item.Add(gm);
                }
            }
            return item;
        }

    }
}
